<?php

namespace app\controller;

use app\BaseController;
use think\facade\View;
use app\logic\LuckyDrawLogLogic;

class Xue extends BaseController
{
    public function index()
    {
        return View::fetch('index');
    }

    public function luckyDraw(LuckyDrawLogLogic $logic)
    {
        if (mt_rand(1, 20) == 1) {
            $msg = '恭喜雪儿宝贝中奖了';
            $logic->add(['ip' => $this->request->ip(), 'lucky_draw' => 1]);
            \Api::success([], 200, $msg);
        } else {
            $list = ['很遗憾没有中了', '再接再厉', '就差一点点了', '不要放弃', '下次就中啦', '下次一定行', '抱歉啥都没有', '加油你一定行'];
            $msg = $list[array_rand($list)];
            $logic->add(['ip' => $this->request->ip(), 'lucky_draw' => 0]);
            \Api::error($msg);
        }
    }
}